#include <iostream>
#include"head.h"
void menu9(Node* phead)
{
	while(1)
	{
		system("cls");
		printf("\n打印表格\n");
    	printf("-------------------------------------\n");
    	printf("               菜单                  \n");
		printf("           1.打印工资计算表\n");
		printf("           2.打印个人工资单\n");
		printf("           3.打印部门工资单\n");
		printf("           4.打印工资汇总表\n");
		printf("           0.退出\n"); 
		printf("-------------------------------------\n");
		printf("请选择（0-4）");
		char option[0];
		while(1){

			scanf("%s", &option);
			if(option[0]>='0'&&option[0]<='4'){
				break;
			}
			else{
				printf("输入错误，重新输入0-4\n");
			}
		}

		int choice;
		choice = option[0]-'0';
		system("cls"); 
		switch(choice)
		{	
    		case 0:
			{
				return ;
			}
			
			case 1:
			{
				print_calculate(phead);

				break;
			}
			
			case 2:
			{
				printf("输入职工姓名：");
				char str[20];
				scanf("%s",str);

				print_Employee(phead, str);

				break;
			}
			
			case 3:
			{
				char str[20];
				printf("输入部门：");
				scanf("%s",str);

				print_department(phead, str);

				break;
			}
			
			case 4:
			{
				print_all(phead);

				break;
			}
			default: continue;	
    	}
	    system("pause");
    }
}

void print_calculate(Node* phead)
{
    printf("姓名:\t基本工资:\t岗位津贴:\t物价补贴:\t职务补贴:\t住房补贴:\t房租费用:\t加班补贴:\t夜班补贴:\t病假扣款:\t事假扣款:\t旷工扣款:\t其他扣款:\t实际工资:\n");

	Node* p = phead->next;
	while(p != NULL)
	{
		Employee* E = (Employee*)p->data;

		printf("%s:\t+%lf\t+%lf\t+%lf\t+%lf\t+%lf\t-%lf\t+%lf\t+%lf\t-%lf\t-%lf\t-%lf\t-%lf\t%lf\n", E->name, E->base_pay, E->job_subisidy, E->escalsting_wage, E->wage_sttached_to_a_post, E->housing_add, E->chummage, E->ovrtime_pay, E->night_duty_allowance, E->sick_leave_deduction, E->personal_leave_deduction, E->absenteism_deduction, E->other_deductions, E->net_payroll);

		p = p->next;
	}
}

void print_Employee(Node* phead, char str[20])
{
    printf("姓名:\t基本工资:\t岗位津贴:\t物价补贴:\t职务补贴:\t住房补贴:\t房租费用:\t加班补贴:\t夜班补贴:\t病假扣款:\t事假扣款:\t旷工扣款:\t其他扣款:\t实际工资:\n");

	Node* p = phead->next;
	while(p != NULL)
	{
		Employee* E = (Employee*)p->data;

		if (strcmp(E->name,str) == 0)
		{
		printf("%s:\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", E->name, E->base_pay, E->job_subisidy, E->escalsting_wage, E->wage_sttached_to_a_post, E->housing_add, E->chummage, E->ovrtime_pay, E->night_duty_allowance, E->sick_leave_deduction, E->personal_leave_deduction, E->absenteism_deduction, E->other_deductions, E->net_payroll);

		}
		p = p->next;
	}
}

void print_department(Node* phead, char str[20])
{
    printf("姓名:\t基本工资:\t岗位津贴:\t物价补贴:\t职务补贴:\t住房补贴:\t房租费用:\t加班补贴:\t夜班补贴:\t病假扣款:\t事假扣款:\t旷工扣款:\t其他扣款:\t实际工资:\n");

	Node* p = phead->next;
	while(p != NULL)
	{
		Employee* E = (Employee*)p->data;

		if (strcmp(E->department,str) == 0)
		{
			printf("%s:\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", E->name, E->base_pay, E->job_subisidy, E->escalsting_wage, E->wage_sttached_to_a_post, E->housing_add, E->chummage, E->ovrtime_pay, E->night_duty_allowance, E->sick_leave_deduction, E->personal_leave_deduction, E->absenteism_deduction, E->other_deductions, E->net_payroll);

		}
		p = p->next;
	}
}

void print_all(Node* phead)
{
    printf("姓名:\t基本工资:\t岗位津贴:\t物价补贴:\t职务补贴:\t住房补贴:\t房租费用:\t加班补贴:\t夜班补贴:\t病假扣款:\t事假扣款:\t旷工扣款:\t其他扣款:\t实际工资:\n");

	Node* p = phead->next;
	while(p != NULL)
	{
		Employee* E = (Employee*)p->data;

		printf("%s:\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", E->name, E->base_pay, E->job_subisidy, E->escalsting_wage, E->wage_sttached_to_a_post, E->housing_add, E->chummage, E->ovrtime_pay, E->night_duty_allowance, E->sick_leave_deduction, E->personal_leave_deduction, E->absenteism_deduction, E->other_deductions, E->net_payroll);

		p = p->next;
	}
}
